package PolymorphicHomeworkTest5;
/*
长方形类
 */
public class Rectangle extends Graph{
    private double side;
    private double wide;

    public Rectangle(){

    }
    public Rectangle(String color,boolean fill,double side,double wide){
        super(color,fill);
        this.side = side;
        this.wide = wide;
    }

    public double getSide() {
        return side;
    }

    public void setSide(double side) {
        this.side = side;
    }

    public double getWide() {
        return wide;
    }

    public void setWide(double wide) {
        this.wide = wide;
    }

    @Override
    public String toString() {
        return "长方形{" + "长=" + side + ", 宽=" + wide + " 颜色="+super.getColor()
                + (super.isFill() ? " 填充":" 无填充")+'}';
    }

    public void getArea(){                      //重写父类抽象方法，获取面积
        double area = this.side * this.wide;
        System.out.println("长方形面积是"+area);
    }

    public void getPerimeter(){                 //重写父类抽象方法，获取周长
        double perimeter = 2 * (this.side + this.wide);
        System.out.println("长方形周长是"+perimeter);
    }
}
